package com.green.web.util;

import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;

public class OptionComparator implements Comparator<String> {

	private OptionComparator(){
		
	}
	
	public static OptionComparator getInstance(){
		return OptionComparatorHolder.oc;
	}
	
	private final  Map<String,Integer> order;
	{
		order=new HashMap<String,Integer>();
		order.put("优", 1);
		order.put("良", 2);
		order.put("中", 3);
		order.put("差", 4);
		order.put("有", 1);
		order.put("没有", 2);
		order.put("中庸回答", 3);
		order.put("总计", 4);
	}
	
	@Override
	public int compare(String o1, String o2) {
		//有对象为空，返回相等(这里还没想好怎么排)
		if(o1==null || o2==null){
			return 0;
		}
		Integer number1=order.get(o1);
		Integer number2=order.get(o2);
		if(number1==null || number2==null){
			return 0;
		}
		return number1-number2;
	}

	private static class OptionComparatorHolder{
		private static OptionComparator oc=new OptionComparator(); 
	}
}
